<script>
export default {
    name: "My",
    data(){
        return {
            username:localStorage.getItem("username")
        }
    },
    methods:{
        outLogin(){
            localStorage.clear();
            this.$router.push({
                path:"/login",
                query:{
                    returnUrl:this.$route.fullPath
                }
            });
        }
    },
    // beforeRouteEnter(to,from,next){
    //     console.log("beforeRouteEnter")
    //     next();
    // }
}
</script>

<template>
    <div>
        <h3>欢迎<span style="color:red">{{username}}</span>的到来</h3>
        <button @click="outLogin">退出登陆</button>
    </div>

</template>

<style scoped>

</style>